package com.example.demo.service.impl;

import com.example.demo.mapper.PersonalityTypeMapper;
import com.example.demo.model.PersonalityType;
import com.example.demo.service.PersonalityTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class PersonalityTypeServiceImpl implements PersonalityTypeService {
    
    @Autowired
    private PersonalityTypeMapper personalityTypeMapper;

    @Override
    public PersonalityType findById(Integer id) {
        return personalityTypeMapper.findById(id);
    }

    @Override
    public PersonalityType findByCode(String code) {
        return personalityTypeMapper.findByCode(code);
    }

    @Override
    public List<PersonalityType> findAll() {
        return personalityTypeMapper.findAll();
    }

    @Override
    @Transactional
    public PersonalityType create(PersonalityType personalityType) {
        personalityTypeMapper.insert(personalityType);
        return personalityType;
    }

    @Override
    @Transactional
    public PersonalityType update(PersonalityType personalityType) {
        personalityTypeMapper.update(personalityType);
        return personalityType;
    }

    @Override
    @Transactional
    public Boolean deleteById(Integer id) {
        personalityTypeMapper.deleteById(id);
        return true;
    }
} 